package cn.richard.databind.model

import android.widget.TextView
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import androidx.databinding.BindingAdapter
import cn.richard.databind.BR

/**
 *
 * @ProjectName: CaseApp
 * @Author: wuzhiguo@aiforward.com
 * @CreateDate: 2021/8/27 3:05 下午
 * @Description:
 */
class UserModel : BaseObservable() {

    @get:Bindable
    var name: String = ""
        set(value) {
            field = value
            notifyPropertyChanged(BR.name)
        }

    @get:Bindable
    var age: Int = 0
        set(value) {
            field = value
            notifyPropertyChanged(BR.age)
        }

    companion object {
        @JvmStatic
        @BindingAdapter(value = ["user_name", "user_age"], requireAll = true)
        fun setUser(view: TextView, user_name: String, user_age: Int) {
            view.text = "我的名字是：${user_name}，我今年${user_age}岁了"
        }
    }
}
